package com.sunyard;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class CombileFile {
	public static void main(String[] args) {
		File path = new File("R:/TEMP");
		File result = new File(path, "com.jpg");
		File[] files = path.listFiles();
		int i = 0;

		int len = 0;
		byte[] bt = new byte[1024];
		try {
			OutputStream os = new FileOutputStream(result);
			for (; i < files.length; i++) {
				if (files[i].isDirectory()) {
					continue;
				}
				InputStream is = new FileInputStream(files[i]);
				while ((len = is.read(bt)) > 0) {
					os.write(bt, 0, len);
				}
				is.close();
			}
			os.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
